/**
 * @file   Graph.h
 * @author zhang-zh
 * @date   2020/12/27 Sunday
 * 
 * @brief  A headfile of Graph.
 * 
 */

#ifndef __zhang_graph__
#define __zhang_graph__

#include <iostream>
#include <vector>
#include <limits>

#define MIN (std::numeric_limits<double>::min())

using namespace std;

struct Edge 
{
    int ori;   //The origin of the edge.
    int dest;  //The destination of the edge.
    double weight;  //The weight or the length of the edge.

    //Edge(int _ori, int _dest, double _weight):ori(_ori), dest(_dest), weight(_weight){};
    //Edge(){};
};

typedef pair<int, double> Pair;

class Graph
{
public:
    vector< vector<Pair> > adjList;
    vector< vector<double> > adjMatrix;
    
    Graph(vector<Edge> &edges, int n, int mark)
    {
        if(mark <= 0)
        {
            adjList.resize(n);
            for(auto &edge : edges)
            {
                int i = edge.ori;
                int _x = edge.dest;
                double _y = edge.weight;
                adjList[i].push_back(make_pair(_x, _y));
            }
        }
        else 
        {
            adjMatrix.resize(n);
            for(int i = 0; i < n; i++)
            {
                adjMatrix[i].resize(n);
            }

            for(int i = 0; i < n; i++)
            {
                for(int j = 0; j < n; j++)
                {
                    adjMatrix[i][j] = MIN;
                }
            }

            for(auto &edge : edges)
            {
                int i = edge.ori;
                int j = edge.dest;
                double _y = edge.weight;
                adjMatrix[i][j] = _y;
            }
        }

    }
};



#endif